import { Component, OnInit, ViewChild, ViewContainerRef, ComponentRef, ComponentFactoryResolver, EventEmitter } from '@angular/core';
import * as _ from 'lodash';
import { ViewPageComponent } from "../../content/view-page/view-page.component";
@Component({
  selector: 'app-view',
  templateUrl: './view.component.html',
  styleUrls: ['./view.component.scss']
})
export class ViewComponent implements OnInit {
  // 模版
  @ViewChild("qdiiViewPage", { read: ViewContainerRef })
  qdiiViewPage: ViewContainerRef;
  viewPageComponent: ComponentRef<ViewPageComponent>;
  constructor(
    public resolver: ComponentFactoryResolver,
  ) { }

  ngOnInit() {
    if (this.viewPageComponent && this.viewPageComponent.instance) {
      this.viewPageComponent.destroy();
    }
    const viewPageComponent = this.resolver.resolveComponentFactory(ViewPageComponent);
    this.viewPageComponent = this.qdiiViewPage.createComponent(viewPageComponent);
  }
}
